package video.others

private const val RELEASEMODE = 0
private const val DEBUG = 1

fun main(args: Array<String>) {

    //以下表达式赋值需要列举所有条件

    //条件表达式
    val mode = if (args.isNotEmpty() && args[0] == "1") DEBUG else RELEASEMODE

    val playMode = Play.PLAYING

    //when表达式
    val whenExpression = when (playMode) {
        Play.STRAT -> "STRAT"
        Play.PLAYING -> "PLAYING"
        Play.PAUSE -> "PAUSE"
        Play.STOP -> "STOP"
    }

    println(whenExpression)

    //try..catch..finally

    val arrayInt = arrayListOf(22, 0, 66)

    val tryExceptionExpression = try {
        arrayInt[0]/arrayInt[1]
    } catch (e: Exception) {
        e.printStackTrace() //1
        0  //2
    } finally {
        println("finally")//2
        1  //并不会返回
    }

    println(tryExceptionExpression)

}

enum class Play {
    STRAT,
    PLAYING,
    PAUSE,
    STOP
}
